package com.zhuojy.equity.mall.admin.common.exception;

import com.zhuojy.equity.mall.admin.common.enums.ErrCdEnum;
import lombok.Getter;

/**
 * 业务异常对象
 */
public class BizException extends RuntimeException {

	private static final long serialVersionUID = -8204964235619292424L;

	@Getter
	private final String errCd;

	@Getter
	private final String errMsg;

	public BizException(ErrCdEnum errCdEnum) {
		super(errCdEnum.getDesc());
		this.errCd = errCdEnum.getCode();
		this.errMsg = errCdEnum.getDesc();
	}

	public BizException(ErrCdEnum errCdEnum, String errMsg) {
		super(errMsg);
		this.errCd = errCdEnum.getCode();
		this.errMsg = errMsg;
	}

	public BizException(String errCd, Throwable throwable) {
		super(throwable);
		this.errCd = errCd;
		this.errMsg = throwable.getMessage();
	}

	public BizException(String errCd, String errMsg) {
		super(errMsg);
		this.errCd = errCd;
		this.errMsg = errMsg;
	}

	public BizException(String errCd, String errMsg, Throwable throwable) {
		super(errMsg, throwable);
		this.errCd = errCd;
		this.errMsg = errMsg;
	}
}
